package com.yida.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.yida.common.core.utils.poi.ExcelUtil;
import com.yida.common.core.web.controller.BaseController;
import com.yida.common.core.web.domain.AjaxResult;
import com.yida.common.core.web.page.TableDataInfo;
import com.yida.common.log.annotation.Log;
import com.yida.common.log.enums.BusinessType;
import com.yida.common.security.annotation.RequiresPermissions;
import com.yida.system.domain.request.SysDataPutInInterfaceConfigEditRequest;
import com.yida.system.domain.request.SysDataPutInInterfaceConfigSaveRequest;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.yida.system.api.domain.SysDataPutInInterfaceConfig;
import com.yida.system.service.ISysDataPutInInterfaceConfigService;


/**
 * 系统数据接入接口配置Controller
 * 
 * @author ruoyi
 * @date 2023-04-04
 */
@RestController
@RequestMapping("/system/data/put/in/interface/config")
@Api(tags = "系统数据接入接口配置")
public class SysDataPutInInterfaceConfigController extends BaseController
{
    @Autowired
    private ISysDataPutInInterfaceConfigService sysPutInInterfaceConfigService;

    /**
     * 查询系统数据接入接口配置列表
     */
    @GetMapping("/list")
    @ApiOperation("查询系统数据接入接口配置列表")
    @RequiresPermissions("system:data:put:in:interface:list")
    public TableDataInfo list(SysDataPutInInterfaceConfig sysPutInInterfaceConfig)
    {
        startPage();
        List<SysDataPutInInterfaceConfig> list = sysPutInInterfaceConfigService.selectSysDataPutInInterfaceConfigList(sysPutInInterfaceConfig);
        return getDataTable(list);
    }

    /**
     * 导出系统数据接入接口配置列表
     */
    @Log(title = "系统数据接入接口配置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation("导出系统数据接入接口配置列表")
    @RequiresPermissions("system:data:put:in:interface:export")
    public void export(HttpServletResponse response, SysDataPutInInterfaceConfig sysPutInInterfaceConfig)
    {
        List<SysDataPutInInterfaceConfig> list = sysPutInInterfaceConfigService.selectSysDataPutInInterfaceConfigList(sysPutInInterfaceConfig);
        ExcelUtil<SysDataPutInInterfaceConfig> util = new ExcelUtil<SysDataPutInInterfaceConfig>(SysDataPutInInterfaceConfig.class);
        util.exportExcel(response, list, "系统数据接入接口配置数据");
    }

    /**
     * 获取系统数据接入接口配置详细信息
     */
    @GetMapping(value = "/{id}")
    @ApiOperation("获取系统数据接入接口配置详细信息")
    @RequiresPermissions("system:data:put:in:interface:list")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(sysPutInInterfaceConfigService.selectSysDataPutInInterfaceConfigById(id));
    }

    /**
     * 新增系统数据接入接口配置
     */
    @Log(title = "系统数据接入接口配置", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增系统数据接入接口配置")
    @RequiresPermissions("system:data:put:in:interface:save")
    public AjaxResult add(@RequestBody @Validated SysDataPutInInterfaceConfigSaveRequest saveRequest)
    {
        return toAjax(sysPutInInterfaceConfigService.insertSysDataPutInInterfaceConfig(saveRequest));
    }

    /**
     * 修改系统数据接入接口配置
     */
    @Log(title = "系统数据接入接口配置", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("修改系统数据接入接口配置")
    @RequiresPermissions("system:data:put:in:interface:edit")
    public AjaxResult edit(@RequestBody @Validated SysDataPutInInterfaceConfigEditRequest editRequest)
    {
        return toAjax(sysPutInInterfaceConfigService.updateSysDataPutInInterfaceConfig(editRequest));
    }

    /**
     * 删除系统数据接入接口配置
     */
    @Log(title = "系统数据接入接口配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    @ApiOperation("删除系统数据接入接口配置")
    @RequiresPermissions("system:data:put:in:interface:config:delete")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sysPutInInterfaceConfigService.deleteSysDataPutInInterfaceConfigByIds(ids));
    }
}
